class Cat:
    def eat(self):
        print("%s爱吃鱼" % self.name)
    def drink(self):
        print("%s爱喝水" % self.name)
tom = Cat()

#tom.name = "Tom"

tom.eat()
tom.drink()
print(tom)
# 当属性设置在调用方法后，就会出错
tom.name = "Tom"